import { getStore } from '@/util/store'
const dic = {
  risk_type: [
    { label: '供应商风险', value: '0' },
    { label: '寻源风险', value: '1' },
    { label: '物料风险', value: '2' },
    { label: '合同风险', value: '3' }
  ],
  riskLevel: [
    { label: 'Y', value: '0' },
    { label: 'R', value: '1' },
    { label: 'A', value: '2' },
    { label: 'G', value: '3' }
  ],
  possibility: [
    { label: '极低的', value: '0' },
    { label: '不太可能的', value: '1' },
    { label: '有小概率可能', value: '2' },
    { label: '有大概率可能', value: '3' },
    { label: '几乎肯定发生', value: '4' }
  ],
  riskResult: [
    { label: '轻微', value: '0' },
    { label: '低的', value: '1' },
    { label: '中等', value: '2' },
    { label: '高的', value: '3' },
    { label: '严重的', value: '4' }
  ],
  riskStatus: [
    { label: '开', value: '0' },
    { label: '关', value: '1' }
  ]
}
export const option = function () {
  return {
    labelWidth: 100,
    emptyBtn: false,
    submitBtn: false,
    detail: ['view'].includes(this.type),
    column: [
      {
        label: '风险编码',
        span: 8,
        prop: 'riskCode',
        maxlength: 100,
        disabled: true
      },
      {
        label: '申请人',
        span: 8,
        prop: 'applicant',
        maxlength: 100,
        disabled: true,
        value: getStore({ name: 'userInfo' }).user_name
      },
      {
        label: '申请时间',
        span: 8,
        prop: 'applyDate',
        type: 'date',
        format: 'yyyy-MM-dd',
        valueFormat: 'yyyy-MM-dd',
        maxlength: 100,
        disabled: true,
        value: new Date()
      },
      {
        label: '风险类型',
        span: 8,
        prop: 'riskType',
        type: 'select',
        dicData: dic.risk_type,
        props: {
          label: 'label',
          value: 'value'
        },
        disabled: ['edit'].includes(this.type),
        rules: [
          {
            required: true,
            message: '请选择风险类型',
            trigger: 'change'
          }
        ]
      },
      {
        label: '类型编码',
        span: 8,
        prop: 'typeCode',
        maxlength: 50,
        formslot: true,
        rules: [
          {
            required: true,
            message: '请选择类型编码',
            trigger: 'change'
          }
        ]
      },
      {
        label: '类型名称',
        span: 8,
        prop: 'typeName',
        maxlength: 50,
        disabled: true
      },
      {
        label: '风险名称',
        span: 8,
        prop: 'riskName',
        maxlength: 50,
        rules: [
          {
            required: true,
            message: '请输入风险名称',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '可能性',
        span: 8,
        prop: 'possibility',
        type: 'select',
        dicData: dic.possibility,
        props: {
          label: 'label',
          value: 'value'
        },
        rules: [
          {
            required: true,
            message: '请选择可能性',
            trigger: 'change'
          }
        ]
      },
      {
        label: '风险结果',
        span: 8,
        prop: 'riskResult',
        type: 'select',
        dicData: dic.riskResult,
        props: {
          label: 'label',
          value: 'value'
        },
        rules: [
          {
            required: true,
            message: '请选择风险结果',
            trigger: 'change'
          }
        ]
      },
      {
        label: '综合风险等级',
        span: 8,
        prop: 'comprehensiveRiskLevel',
        maxlength: 50,
        formslot: true
      },
      {
        label: '风险状态',
        span: 8,
        prop: 'riskStatus',
        type: 'switch',
        props: {
          label: 'label',
          value: 'value'
        },
        dicData: dic.riskStatus,
        display: ['edit','view'].includes(this.type)
      },
      {
        label: '备注',
        prop: 'remark',
        type: 'textarea',
        maxlength: 500,
        minRows: 4,
        maxRows: 5,
        span: 24
      }
    ]
  }
}

export const supplierOption = [
  { label: '选择', prop: 'radio', width: 50 },
  { label: '供应商编码', prop: 'supplierCode' },
  { label: '供应商名称', prop: 'supplierName' },
  { label: '供应商类型', prop: 'supplierType' },
  { label: '供应商身份', prop: 'supplierIdentity' }
]
